﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using System . Collections . ObjectModel;
using System . Xml . Linq;

namespace GameClassLibrary . Maps
{
    /// <summary>
    /// 代表地图上的道路
    /// </summary>
    public class Road : MapObject
    {

        public virtual void Passed ( Players . Player player ) { }

        public bool BlockMoving
        {
            get
            {
                bool blockMoving=false;
                foreach ( var item in Buffs )
                {
                    blockMoving |= item . BlockMoving;
                }
                return blockMoving;
            }
        }

        public bool Jumper
        {
            get
            {
                bool blockJumper=false;
                foreach ( var item in Buffs )
                {
                    blockJumper |= item . Jumper;
                }
                return blockJumper;
            }
        }

        public List<Buffs . RoadBuff> Buffs { get; private set; }

        public override SizeOfMapObject Size
        {
            get
            {
                return SizeOfMapObject . Small;
            }

             set
            {

            }
        }

        public Road ForwardRoad { get; set; }

        public Road BackwardRoad { get; set; }

        public override void UpdateView ( )
        {

        }

        public override void NextDay ( )
        {
            throw new NotImplementedException ( );
        }

        public override XElement Save ( )
        {
            XElement temp=base.Save();

            XElement buff=new XElement("Buffs");

            foreach ( var item in Buffs )
            {
                buff . Add ( item . Save ( ) );
            }

            temp . Add ( buff );

            temp . SetAttributeValue ( "ForwardRoad" , ForwardRoad . Index );
            temp . SetAttributeValue ( "BackwardRoad" , BackwardRoad . Index );

            return temp;
        }

        public Road ( XElement saving ) : base ( saving )
        {
            //ForwardRoad= saving.Attribute( "ForwardRoad" )
        }

    }
}
